home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / pcboard / iemsi120.zip / TO8BIT.PPS < prev   
Text File  |  1996-10-19  |  1KB  |  44 lines

  1.  
  2. ; convert EMSI 7-bit data => 8-bit data
  3. Declare Function To8Bit(BigStr Bit7) BigStr
  4.  
  5. Function To8Bit(BigStr Bit7) BigStr
  6.     Word            x, y
  7.     String        char
  8.     BigStr        str
  9.     BigStr        buffer
  10.  
  11.     ; fairly fast method; seek to escape code and process
  12.     For x = 1 to Len(Bit7)
  13.       ; remaining string to process
  14.         buffer = Right(Bit7, Len(Bit7)-x+1)
  15.         ; seek to escape code
  16.         y = InStr(buffer+"\", "\")-1
  17.         ; add normal characters to output string
  18.         str = str+Left(buffer, y)
  19.         ; set position
  20.         x = x+y
  21.         ; if next character is and escape code, char = backslash
  22.         If (Mid(Bit7, x+1, 1) = "\") Then
  23.             char = "\"
  24.             Inc x
  25.         ; next two characters are part of escape code (assumed)
  26.         Else
  27.             char = Chr(S2I(Mid(Bit7, x+1, 2), 16))
  28.             x = x+2
  29.         EndIf
  30.         ; add characters to output string
  31.         str = str+char
  32.     Next
  33.  
  34.     ; handle special open/close field characters
  35.     str = ReplaceStr(str, "{{", "{")
  36.     str = ReplaceStr(str, "}}", "}")
  37.     str = ReplaceStr(str, "[[", "[")
  38.     str = ReplaceStr(str, "]]", "]")
  39.  
  40.     ; return value
  41.     To8Bit = str
  42. EndFunc
  43.  
  44.